package com.skcc.cip.ngms.ea.processor;

import java.rmi.RemoteException;
import java.util.HashMap;
import java.util.Properties;
import java.util.Vector;

import javax.ejb.CreateException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import org.apache.camel.Exchange;
import org.apache.camel.Processor;

public class CallEJB{
	
	private org.uengine.processmanager.ProcessManagerRemote bean;

	private void init() throws NamingException, RemoteException, CreateException{
		Context ctx = createEjbContext();
		Object t = ctx.lookup("ProcessManagerHomeRemote");
	    
		org.uengine.processmanager.ProcessManagerHomeRemote home =(org.uengine.processmanager.ProcessManagerHomeRemote)t;
	    bean= home.create();
	}
	
	public void getWorkList() throws RemoteException {
		    
		    HashMap paramMap=new HashMap();
		    Vector vc=bean.getWorkList("S0000507", paramMap, 0);
		    System.out.println(vc.toString());
	}

	private static Context createEjbContext() throws NamingException {
	    // here we need to define our context factory to use OpenEJB for our testing
	    Properties properties = new Properties();
	    properties.put(InitialContext.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
	    properties.put(InitialContext.PROVIDER_URL, "jnp://203.235.210.94:1899");
	    properties.put(InitialContext.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
	    properties.put("jnp.disableDiscovery", "false"); 


	    return new InitialContext(properties);
	}
}
